meson: Rebuild the SCSS-based themes if sassc is available
authorEmmanuele Bassi <ebassi@gnome.org>
Thu, 1 Jun 2017 13:56:32 +0000 (14:56 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Thu, 1 Jun 2017 13:56:32 +0000 (14:56 +0100)
If we have sassc installed then we want to rebuild the themes that use
SCSS whenever one of their dependencies change.

gtk/meson.build
gtk/theme/Adwaita/meson.build [new file with mode: 0644]
gtk/theme/HighContrast/meson.build [new file with mode: 0644]

index 8d9550019b3d97131d5a37b422a8985d32e3997f..1209c38e5a93d702d323af40ceb67c3d35a0d150 100644 (file)
@@ -680,9 +680,24 @@ gtk_gresources_xml = configure_file(output: 'gtk.gresources.xml',
                                       outfile
                                     ])
 
+# Re-build the theme files if sassc is available
+theme_deps = []
+sassc = find_program('sassc', required: false)
+if sassc.found()
+  sassc_opts = [ '-a', '-M', '-t', 'compact' ]
+
+  subdir('theme/Adwaita')
+  subdir('theme/HighContrast')
+endif
+
 gtkresources = gnome.compile_resources('gtkresources',
                                        gtk_gresources_xml,
-                                       source_dir: meson.current_source_dir(),
+                                       dependencies: theme_deps,
+                                       source_dir: [
+                                         # List in order of preference
+                                         meson.current_build_dir(),
+                                         meson.current_source_dir(),
+                                       ],
                                        c_name: '_gtk',
                                        extra_args: '--manual-register')
 
diff --git a/gtk/theme/Adwaita/meson.build b/gtk/theme/Adwaita/meson.build
new file mode 100644 (file)
index 0000000..7a799f9
--- /dev/null
@@ -0,0 +1,30 @@
+scss_files = files([
+  '_colors-public.scss',
+  '_colors.scss',
+  '_common.scss',
+  '_drawing.scss',
+])
+
+theme_variants = [
+  'dark',
+]
+
+theme_deps += custom_target('Adwaita',
+                            input: 'gtk-contained.scss',
+                            output: 'gtk-contained.css',
+                            command: [
+                              sassc, sassc_opts, '@INPUT@', '@OUTPUT@',
+                            ],
+                            depend_files: scss_files,
+                            build_by_default: true)
+
+foreach variant: theme_variants
+  theme_deps += custom_target('Adwaita-' + variant,
+                              input: 'gtk-contained-@0@.scss'.format(variant),
+                              output: 'gtk-contained-@0@.css'.format(variant),
+                              command: [
+                                sassc, sassc_opts, '@INPUT@', '@OUTPUT@',
+                              ],
+                              depend_files: scss_files,
+                              build_by_default: true)
+endforeach
diff --git a/gtk/theme/HighContrast/meson.build b/gtk/theme/HighContrast/meson.build
new file mode 100644 (file)
index 0000000..f323035
--- /dev/null
@@ -0,0 +1,29 @@
+scss_files = files([
+  '_colors.scss',
+  '_common.scss',
+  '_drawing.scss',
+])
+
+theme_variants = [
+  'inverse',
+]
+
+theme_deps += custom_target('HighContrast',
+                            input: 'gtk-contained.scss',
+                            output: 'gtk-contained.css',
+                            command: [
+                              sassc, sassc_opts, '@INPUT@', '@OUTPUT@',
+                            ],
+                            depend_files: scss_files,
+                            build_by_default: true)
+
+foreach variant: theme_variants
+  theme_deps += custom_target('HighContrast-' + variant,
+                              input: 'gtk-contained-@0@.scss'.format(variant),
+                              output: 'gtk-contained-@0@.css'.format(variant),
+                              command: [
+                                sassc, sassc_opts, '@INPUT@', '@OUTPUT@',
+                              ],
+                              depend_files: scss_files,
+                              build_by_default: true)
+endforeach